{include file="public/layout" /}
<script type="text/javascript" src="__SKIN__/js/clipboard.min.js"></script>
<body class="bodystyle" style="cursor: default; -moz-user-select: inherit;min-width:auto;">
<div id="append_parent"></div>
<div id="ajaxwaitid"></div>
<div class="page min-hg-c-10" style="min-width:auto;">
    <div class="flexigrid">
        <div class="mDiv pt0">
            <div class="ftitle">
                <h3>变量列表</h3>
                <h5>(共{$pageObj->totalRows}条数据)</h5>
            </div>
            <form class="navbar-form form-inline" action="{:url('Language/official_pack_index')}" method="get" onsubmit="layer_loading('正在处理');">
                {$searchform.hidden|default=''}
                <div class="sDiv">
                    <div class="sDiv2">
                        <input type="text" size="30" name="keywords" value="{$Request.param.keywords}" class="qsbox" placeholder="变量值搜索...">
                        <input type="submit" class="btn" value="搜索">
                        <i class="iconfont e-sousuo"></i>
                    </div>
                </div>
            </form>
        </div>
        <div class="hDiv">
            <div class="hDivBox">
                <table cellspacing="0" cellpadding="0" style="width: 100%">
                    <thead>
                    <tr>
                        <th class="sign w10" axis="col0">
                            <div class="tc"></div>
                        </th>
                        <th abbr="article_time" axis="col6" class="w150">
                            <div class="tl text-l10">变量名</div>
                        </th>
                        <th abbr="article_title" axis="col3" class="">
                            <div class="tl text-l10">变量值</div>
                        </th>
                        <th abbr="article_time" axis="col6" class="w100">
                            <div class="tc">更新时间</div>
                        </th>
                        <th axis="col1" class="w160">
                            <div class="tc">操作</div>
                        </th>
                    </tr>
                    </thead>
                </table>
            </div>
        </div>
        <div class="bDiv" style="height: auto;">
            <div id="flexigrid" cellpadding="0" cellspacing="0" border="0">
                <table style="width: 100%;">
                    <tbody>
                    {empty name="list"}
                        <tr>
                            <td class="no-data" align="center" axis="col0" colspan="50">
                                <div class="no_row">
                                    <div class="no_pic"><img src="__SKIN__/images/null-data.png"></div>
                                </div>
                            </td>
                        </tr>
                    {else/}
                        {foreach name="list" item="vo" key="k" }
                        <tr>
                            <td class="">
                                <div class="w10 tc">
                                </div>
                            </td>
                            <td class="">
                                <div class="w150 tl text-l10">
                                    <a href="{:url('Language/pack_edit',array('id'=>$vo['id']))}">{$vo.name}</a>
                                </div>
                            </td>
                            <td class="" style="width: 100%;">
                                <div class="tl text-l10" >
                                    {$vo.value|htmlentities=###}
                                </div>
                            </td>
                            <td>
                                <div class="w100 tc">
                                    {$vo.update_time|date='Y-m-d',###}
                                </div>
                            </td>
                            <td class="operation">
                                <div class="w160 tc">
                                    {eq name="'Language@pack_edit'|is_check_access" value="1"}
                                    <a href="javascript:void(0);" data-href="{:url('Language/pack_edit',array('id'=>$vo['id'],'official'=>1))}" onclick="openFullframe(this, '编辑语言包变量', '600px', '430px');" class="btn blue">编辑</a>
                                    <i></i>
                                    {/eq}
                                    <a href="javascript:void(0);" onclick="showtext('{$vo['name']}');" class="btn blue {$vo['name']}" data-clipboard-text="{{php} echo 'eyou:lang name=\'';{/php}{$vo['name']}{php} echo '\' /';{/php}}">复制标签</a>
                                </div>
                            </td>
                        </tr>
                        {/foreach}
                    {/empty}
                    </tbody>
                </table>
            </div>
            <div class="iDiv" style="display: none;"></div>
        </div>
        <!--分页位置-->
        {$pageStr}
    </div>
</div>
<script type="text/javascript">
    $(document).ready(function(){

        // 表格行点击选中切换
        $('#flexigrid > table>tbody >tr').click(function(){
            $(this).toggleClass('trSelected');
        });

        // 点击刷新数据
        $('.fa-refresh').click(function(){
            location.href = location.href;
        });

        check_pack_syn();
        function check_pack_syn()
        {
            $.ajax({
                type : 'post',
                url : "{:url('Language/check_pack_syn')}",
                data : {_ajax:1},
                dataType : 'json',
                success : function(data){
                    if(data.code == 0){
                        layer.alert('官方发布新的通用语言包，确认同步？', {
                            icon: 3,
                            shade: layer_shade,
                            title:false,
                            btn: ['立即同步']
                        }, function(){
                            layer_loading('正在处理');
                            // 确定
                            $.ajax({
                                type : 'post',
                                url : "{:url('Language/pack_syn')}",
                                data : {_ajax:1},
                                dataType : 'json',
                                success : function(res){
                                    layer.closeAll();
                                    if(res.code == 1){
                                        layer.msg(res.msg, {icon: 1, time:500}, function(){
                                            window.location.reload();
                                        });
                                    }else{
                                        layer.alert(res.msg, {icon: 2, title:false}, function(){
                                            window.location.reload();
                                        });
                                    }
                                }
                            })
                        });
                    }
                }
            })
        }
    });

    // 复制标签
    function showtext(classname){
        var clipboard1 = new Clipboard("."+classname);clipboard1.on("success", function(e) {layer.msg("复制成功");});clipboard1.on("error", function(e) {layer.msg("复制失败！请手动复制", {icon:5});}); 
    } 
</script>

{include file="public/footer" /}